# Contributor: Carlo Landmeter <clandmeter@alpinelinux.org>
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=ipmitool
_pkgname=IPMITOOL
pkgver=1.8.18
_pkgver=${pkgver//./_}
pkgrel=10
pkgdesc="Command-line interface to IPMI-enabled devices"
url="https://github.com/ipmitool/ipmitool"
arch="all"
license="MIT"
makedepends="automake autoconf libtool readline-dev openssl1.1-compat-dev ncurses-dev"
subpackages="$pkgname-doc $pkgname-openrc::noarch"
source="$pkgname-$pkgver.tar.gz::https://github.com/ipmitool/ipmitool/archive/${_pkgname}_$_pkgver.tar.gz
	ipmievd.initd
	ipmievd.confd
	openssl-1.1.patch
	https://github.com/ipmitool/ipmitool/commit/7ccea283dd62a05a320c1921e3d8d71a87772637.patch
	gcc-10.patch
	"
builddir="$srcdir/$pkgname-${_pkgname}_$_pkgver"

# secfixes:
#   1.8.18-r9:
#     - CVE-2020-5208

prepare() {
	default_prepare
	autoreconf -vif
}

build() {
	./configure \
		--prefix=/usr \
		--sysconfdir=/etc \
		--mandir=/usr/share/man \
		--infodir=/usr/share/info \
		--localstatedir=/var \
		--bindir=/usr/sbin \
		--enable-ipmievd \
		--enable-ipmishell \
		--enable-intf-lan \
		--enable-intf-lanplus \
		--enable-intf-open \
		--disable-intf-free \
		--disable-intf-imb \
		--disable-intf-lipmi \
		--disable-intf-bmc \
		--disable-internal-md5 \
		--with-kerneldir=/usr
	make
}

check() {
	make check
}

package() {
	make DESTDIR="$pkgdir" install
	install -D -m755 "$srcdir"/ipmievd.initd "$pkgdir"/etc/init.d/ipmievd
	install -D -m644 "$srcdir"/ipmievd.confd "$pkgdir"/etc/conf.d/ipmievd
}

sha512sums="2f2b9c4ce76eb2afdac168edbd41241352c2d4d18286494ffb57dcf750f18448d144543faa8a5494f077c78a4f5ae730624d3798ba6e621249c42fd868d86406  ipmitool-1.8.18.tar.gz
665adc32529df8d5f6598d33ba92175c46e8a5b74094d22553b0265fe817b023c909688af2b02041a37b7cfd3805e6ae74b943fad48970d45564ea8d08309fa6  ipmievd.initd
4cace868f1776a96736b7460c84f525d63d6f53531f1f3e62f0337741dc36fb5b2ee9706fdae6a7b853e98d3894376949797ddc254248bd42dc79d85742c1744  ipmievd.confd
af2181d2ccf66b4e0cf11f3d5a8159afac521024da2ecc1c49af459389bd6fc2f3828d5462a5d7a21cd520e287e50164f0917825778966e3f544f7f06bfa0d35  openssl-1.1.patch
efdba12a1b484d3155fd06448186489a6477face81c47437a3b907a5120b38a885841cd24cecea725af86bf246eca493a51452ad0615acb9eb1c4f47a5c80ed0  7ccea283dd62a05a320c1921e3d8d71a87772637.patch
4f51aab99809d3c64ed47e61c8de6b93b8a788c3cfa6e87faf17894cda85aa5b7293e1d29813dcf1335a3c5eb64dc1f8f1657ca09adb248cf3aaffe64f5d3cb5  gcc-10.patch"
